//
//  CCString.swift
//  SwiftUtils
//
//  Created by wangyu on 10/28/21.
//

import Foundation

extension String {
    // 字串
    func substring(start : Int, length : Int) -> String {
        guard start < self.count else { return "" }
        var _length: Int = length
        if (start + length >= self.count) {
            _length = self.count - start
        }
        
        let start = self.index(self.startIndex, offsetBy: start)
        let end = self.index(start, offsetBy: _length)
        return String(self[start..<end])
    }
}
